<template>
  <div class="app-container">
    <div class="change">
      <el-divider content-position="left">发货单信息：</el-divider>
      <p>
        <span>单据号：</span>
        <span>{{tempData.danjuhao}}</span>
      </p>
      <p>
        <span>发货日期：</span>
        <span>{{tempData.danjuriqi}}</span>
      </p>
      <p>
        <span>业务员：</span>
        <span>{{tempData.yewuyuan}}</span>
      </p>
      <p>
        <span>运输方式：</span>
        <span>{{tempData.fangshi}}</span>
      </p>
      <p>
        <span>收获客户：</span>
        <span>{{tempData.shouhuokehu}}</span>
      </p>
      <p>
        <span>物料名：</span>
        <span>{{tempData.wuliaomingcheng}}</span>
      </p>
      <p>
        <span>包装物：</span>
        <span>{{tempData.bzw}}</span>
      </p>
      <p>
        <span>数量：</span>
        <span>{{tempData.shuliang}}</span>
      </p>
      <p>
        <span>含税单价：</span>
        <span>{{tempData.hanshuidanjia}}</span>
      </p>
      <p>
        <span>价税合计：</span>
        <span>{{tempData.jiashuiheji}}</span>
      </p>
      <p>
        <span>打托缠膜：</span>
        <span>{{tempData.chanmofeiyong}}</span>
      </p>
      <p>
        <span>运输单价：</span>
        <span>{{tempData.yunshudanjia}}</span>
      </p>
      <p>
        <span>包装费用：</span>
        <span>{{tempData.domesticBaozhuang.buhanbaozhuang}}</span>
      </p>
      <p>
        <span>新客户：</span>
        <span>{{tempData.shifouweixinkehu}}</span>
      </p>
      <p>
        <span>佣金：</span>
        <span>{{tempData.yongjin}}</span>
      </p>
      <p>
        <span>收款协议：</span>
        <span>{{tempData.shoukuanxieyi}}</span>
      </p>
      <p>
        <span>佣金比例：</span>
        <span>{{tempData.yongjinbili}}</span>
      </p>
    </div>
    <div class="change">
      <el-divider content-position="left">回款单信息：</el-divider>
      <el-table :data="tempData.huikuanList" style="width: 100%;border-radius: 8px;">
        <el-table-column align="center" prop="huikuanriqi" label="回款日期" />
        <el-table-column align="center" prop="xingming" label="业务员" />
        <el-table-column align="center" prop="kehumingcheng" label="收获客户" />
        <el-table-column align="center" prop="jine" label="回款金额" />
        <el-table-column align="center" prop="jine2" label="回款备份" />
        <el-table-column align="center" prop="chengduiriqi" label="承兑日期" />
        <el-table-column align="center" prop="insertTime" label="导入时间" />
      </el-table>
    </div>
    <div class="change">
      <table class="table table-bordered table-condensed">
        <!-- <caption style="color: red;">金丹销售提成表:</caption> -->
        <tr>
          <td>业务员: {{tempData.yewuyuan}}</td>
          <td colspan="3" style="text-align: center;">金丹销售提成表</td>
          <td>收款协议：{{tempData.shoukuanxieyi}}</td>
          <td>打托缠膜: {{tempData.chanmofeiyong}}</td>
        </tr>
        <tr>
          <td>单号: {{tempData.danjuhao}}</td>
          <td>单据日期: {{tempData.danjuriqi}}</td>
          <td>含税单价: {{tempData.hanshuidanjia}}</td>
          <td>运输方式: {{tempData.fangshi}}</td>
          <td>收获客户: {{tempData.shouhuokehu}}</td>
          <td>物料名称: {{tempData.wuliaomingcheng}}</td>
          <!-- <td>打托缠膜: {{tempData.chanmofeiyong}}</td> -->
        </tr>
        <tr>
          <td>包装物: {{tempData.bzw}}</td>
          <td>数量: {{tempData.shuliang}}</td>
          <td>价税合计: {{tempData.jiashuiheji}}</td>
          <td>运输单价: {{tempData.yunshudanjia}}</td>
          <td>包装单价: {{tempData.domesticBaozhuang.buhanbaozhuang}}</td>
          <td>新客户：{{tempData.shifouweixinkehu}}</td>
        </tr>
        <tbody v-if="tempData.huikuanList.length != 0" v-for="(item,index) in tempData.huikuanList" :key="index">
          <tr>
            <td>客户回款金额: {{item.jine2}}</td>
            <td>客户余额: {{item.jine}}</td>
            <td>回款日期：{{item.huikuanriqi}}</td>
            <td>承兑日期: {{item.chengduiriqi}}</td>
            <td>佣金: {{tempData.yongjin}}</td>
            <td>佣金返点: {{tempData.yongjinbili}}</td>
          </tr>
          <tr>
            <td colspan="4" v-if='item.xiankuanjiangbili != 0'>先款奖: ( {{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}} {{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}} ) * {{item.xiankuanjiangbili}} * {{item.shijishiyongjine/tempData.hanshuidanjia}} </td>
            <td colspan="4" v-else>先款奖: {{item.xiankuanjiang}}</td>
            <td>先款奖: {{item.xiankuanjiang}}</td>
            <td colspan="2">实际使用金额：{{item.shijishiyongjine}}</td>
          </tr>
          <tr>
            <td colspan="4" v-if="item.lixijiangbili == '0.01/30*0.4'">利息奖: {{item.yufutianshu}} * ( {{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}} ) * {{item.lixijiangbili}} * {{item.shijishiyongjine/tempData.hanshuidanjia}}</td>
            <td colspan="4" v-if="item.lixijiangbili == '0.01/30*0.04'">利息奖: {{item.yufutianshu}} * ( {{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}} ) * {{item.lixijiangbili}} * {{item.shijishiyongjine/tempData.hanshuidanjia}}</td>
            <td colspan="4" v-if="item.lixijiangbili == '0.01/30*0.05'">利息奖: {{item.yufutianshu}} * ( {{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}} ) * {{item.lixijiangbili}} * {{item.shijishiyongjine/tempData.hanshuidanjia}}</td>
            <td>利息奖: {{item.lixijiang}}</td>
            <td colspan="2"></td>
          </tr>
        </tbody>
        <tbody v-if="tempData.huikuanList.length == 0">
          <!-- <tr>
            <td>客户回款金额: {{item.jine2}}</td>
            <td>客户余额: {{item.jine}}</td>
            <td>回款日期：{{item.huikuanriqi}}</td>
            <td>承兑日期: {{item.chengduiriqi}}</td>
            <td>佣金: {{tempData.yongjin}}</td>
            <td>佣金返点: {{tempData.yongjinbili}}</td>
          </tr> -->
          <tr>
            <td colspan="4">先款奖: 0</td>
            <td>先款奖: 0</td>
            <td>实际使用金额：</td>
          </tr>
          <tr>
            <td colspan="4">利息奖: 0</td>
            <td>利息奖: 0</td>
            <td colspan="2"></td>
          </tr>
        </tbody>
        <tr>
          <!-- 提成比例 * 净水金额 * 吨位 -->
          <td colspan="4" v-if='tempData.jijiatichengbili == 0.0015'>基价提成:{{tempData.jijiatichengbili}} * （{{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}}） * {{tempData.shuliang}}</td>
          <!-- 提成比例 * 净水金额 * 吨位 -->
          <td colspan="4" v-if='tempData.jijiatichengbili == 0.0035'>基价提成:{{tempData.jijiatichengbili}} * （{{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}}） * {{tempData.shuliang}}</td>
          <!-- 提成比例 * 净水金额 * 吨位 -->
          <td colspan="4" v-if='tempData.jijiatichengbili == 0.002'>基价提成:{{tempData.jijiatichengbili}} * （{{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}}） * {{tempData.shuliang}}</td>
          <!-- 提成比例 * 净水金额 * 吨位 -->
          <td colspan="4" v-if='tempData.jijiatichengbili == 0.004'>基价提成:{{tempData.jijiatichengbili}} * （{{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}}） * {{tempData.shuliang}}</td>
          <!-- 提成比例 * 第五档基价 + 价税比例 *（净水金额 - 第五档基价）* 吨位 -->
          <td colspan="4" v-if='tempData.jijiatichengbili == 0.0045'>基价提成:({{tempData.jijiatichengbili}} * {{tempData.domesticJijiabiao.diwudang}} + {{tempData.domesticXishu.jingshui3b}}*({{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}} - {{tempData.domesticJijiabiao.diwudang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}})) * {{tempData.shuliang}}</td>
          <!-- 提成比例 * 第五档基价 + 价税比例 *（净水金额 - 第五档基价）* 吨位 -->
          <td colspan="4" v-if='tempData.jijiatichengbili == 0.006'>基价提成:({{tempData.jijiatichengbili}} * {{tempData.domesticJijiabiao.diwudang}} + {{tempData.domesticXishu.xinkehu3b}}*({{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}} - {{tempData.domesticJijiabiao.diwudang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}})) * {{tempData.shuliang}}</td>
          <td colspan="4" v-if='tempData.jijiatichengbili == 0'>基价提成:0</td>
          <td colspan="3">基价提成: {{tempData.jijiaticheng}}</td>
        </tr>
        <tr>
          <td colspan="4">计算日期:{{tempData.jisuanriqi}}</td>
          <td colspan="3">合计: {{heji}}</td>
        </tr>
      </table>
    </div>

    <div class="submits">
      <!-- <div class="nosave" @click="nosaveOrder">取消</div> -->
      <div class="save" @click="back">返回</div>
    </div>
  </div>
</template>

<script>
import { idSearchDetail } from "@/api/neimao";
export default {
  data() {
    return {
      tempData: {},
      islook: false,
      tableData: [],
      fileNum: [],
      twoClassify: [],
      huikuanlist: [],
      writeOradd: 0, //新增0，编辑1
      heji: 0
    };
  },
  mounted() {
    // this.cangkuList();
    console.log(this.$route.params);
    const temp = JSON.parse(this.$route.params.options);
    // this.tempData = JSON.parse(this.$route.params.options);
    // console.log(this.tempData)
    this.getdetail(temp.id);
  },
  methods: {
    getdetail(id) {
      const loading = this.$loading({
        lock: true,
        text: '加载中请稍等...',
        spinner: 'el-icon-loading',
        background: 'rgba(255, 255, 255, 0.8)'
      })
      idSearchDetail(id).then(res => {
        console.log(res);
        this.tempData = res.data;
        const hkje = res.data.huikuanList.reduce((total,current) => {
          return total+=current.lixijiang*1 + current.xiankuanjiang*1
        },0)
        this.heji = (hkje + res.data.jijiaticheng*1).toFixed(2)
        console.log(this.heji)
        loading.close()
      }).catch(() => {
        loading.close()
      })
    },
    downloadFile(item) {
      window.location.href = item.fileId;
    },
    // 获取商品文档信息
    getFilesList(id) {
      getUserFiles({ parentId: id }).then(res => {
        console.log(res);
        if (res.data.list.length != 0) {
          this.fileNum = [];
          res.data.list.map(item => {
            this.fileNum.push({
              filename: item.fileDescribe,
              filePath: item.fileName
            });
          });
        }
      });
    },
    // 选择商品分类
    handleChange(value) {
      console.log(value);
      this.tempData.goodsId = value[1];
    },
    downLoad(filepath) {
      window.location.href = filepath;
    },
    nosaveOrder() {
      this.$router.go(-1);
    },
    back() {
      this.$router.go(-1);
    }
  }
};
</script>

<style scoped lang="scss">
.table {
  width: 100%;
  border: 1px solid #000000; /* 整体表格边框 */
  border-collapse: collapse;
}
td {
  border: 1px solid #000000;
  font-size: 13px;
  padding: 5px;
}
.container-fluid {
  display: flex;
  align-items: center;
  border: 1px solid #000;
  border-top: none;
  padding: 5px 0;
}
.foot1 {
  flex: 1;
  font-size: 14px;
}
.ellisp {
  width: 100%;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  text-align: left;
}
.proimg {
  width: 100px;
  height: 100px;
}
.zishebei {
  background: #fff;
  padding: 20px;
  border-radius: 0 0 8px 8px;
}
/deep/.el-table {
  overflow: visible;
}
.change {
  display: flex;
  flex-wrap: wrap;
  background: #fff;
  border-radius: 8px 8px 0 0;
  padding: 20px;
  > p {
    width: 33%;
    font-size: 14px;
    display: flex;
    align-items: center;
    color: #333;
    /deep/.el-input__inner {
      // width: inherit;
      background: none;
      height: 32px;
      // line-height: 32px;
      color: #333;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding: 0 25px;
    }
    /deep/.el-input__icon {
      line-height: 32px;
    }
    .userselect {
      // max-width: 250px;
      flex: 1;
    }

    > span {
      display: block;
      width: 120px;
      text-align: right;
      padding-right: 15px;
      &:last-child {
        text-align: left;
        color: #888;
        flex: 1;
      }
    }
    > input {
      width: inherit;
      flex: 1;
      height: 32px;
      border-radius: 3px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding-left: 10px;
      color: #333;
    }
  }
}
.submits {
  display: flex;
  padding: 15px 20px;
  background: #fff;
  margin-top: 20px;
  border-radius: 8px;
  justify-content: flex-end;
  align-items: center;
  > div {
    width: 80px;
    height: 32px;
    text-align: center;
    line-height: 32px;
    color: #fff;
    font-size: 14px;
    border-radius: 4px;
    margin-left: 30px;
    cursor: pointer;
  }
  .add {
    background: #18a05e;
  }
  .save {
    background: #2196f3;
  }
  .nosave {
    background: #999;
  }
}
.fileup {
  position: relative;
  padding: 20px;
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  // align-items: center;
  justify-content: space-between;
  .uping {
    width: 49%;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    border-radius: 5px;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
    > p {
      width: 90%;
      font-size: 14px;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      color: #333;
      /deep/.el-input__inner {
        // width: inherit;
        background: none;
        height: 32px;
        // line-height: 32px;
        color: #333;
        border: 1px solid rgba(0, 0, 0, 0.1);
        padding: 0 25px;
      }
      /deep/.el-input__icon {
        line-height: 32px;
      }
      /deep/.el-upload-dragger {
        width: 100%;
        height: 100px;
      }
      /deep/.el-upload-dragger .el-icon-upload {
        font-size: 60px;
        color: #c0c4cc;
        margin: 0;
        line-height: 1;
        width: 100%;
      }
      /deep/.el-upload {
        width: 100%;
      }
      .userselect {
        // max-width: 250px;
        flex: 1;
      }

      > span {
        display: block;
        width: 100px;
        text-align: right;
        padding-right: 15px;
        &:last-child {
          text-align: left;
          color: #888;
        }
      }
      > input {
        width: inherit;
        flex: 1;
        height: 32px;
        border-radius: 3px;
        border: 1px solid rgba(0, 0, 0, 0.1);
        padding-left: 10px;
        color: #333;
      }
      > strong {
        display: inline-block;
        padding-right: 50px;
        font-weight: 100;
        font-size: 14px;
        &:last-child {
          cursor: pointer;
          color: #13ce66;
          font-weight: 600;
        }
      }
      > div {
        width: inherit;
        flex: 1;
      }
    }
  }
}
.zd3-btm {
  background: rgba(255, 255, 255, 1);
  border-radius: 8px;
  // border: 1px solid rgba(0, 0, 0, 0.1);
  margin-top: 20px;
  overflow: hidden;
  &-title {
    display: flex;
    align-items: center;
    height: 70px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: #ffffff;
    > p {
      text-align: center;
      font-size: 16px;
      color: #333;
    }
  }
  .el-pagination {
    white-space: nowrap;
    padding: 15px 5px;
    color: #303133;
    font-weight: bold;
  }
  .addDate {
    margin: 20px 32px 10px 32px;
    height: 32px;
    border-radius: 3px;
    text-align: center;
    line-height: 32px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    border: 1px dashed rgba(0, 0, 0, 0.25);
  }
  .el-button--text {
    margin: 0 15px;
  }
}
</style>
